package com.guoheng.hazard.sys.controller.hazard;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.hazard.MajorHazardExamineDTO;
import com.guoheng.hazard.sys.model.dto.hazard.MajorHazardInfoInsertDTO;
import com.guoheng.hazard.sys.model.dto.hazard.MajorHazardInfoUpdateDTO;
import com.guoheng.hazard.sys.service.hazard.MajorHazardInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　MajorHazardInfoController
 *
 * @author fbl
 * @date 2019-11-15 15:32
 */
@RestController
@Validated
@Api(value = "重大危险源信息表")
public class MajorHazardInfoController {

    @Resource
    MajorHazardInfoService majorHazardInfoService;

    @ApiOperation(value = "查询重大危险源信息表")
    @GetMapping(value = "data/major/hazard/infos")
    public Result getHazardInfo(String majorHazardNo, Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return majorHazardInfoService.getHazardInfo(majorHazardNo, entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改重大危险源信息表")
    @PutMapping(value = "data/major/hazard/info")
    public Result updateHazardInfo(@RequestBody @Valid MajorHazardInfoUpdateDTO majorHazardInfoUpdateDTO) {
        return majorHazardInfoService.updateHazardInfo(majorHazardInfoUpdateDTO);
    }

    @ApiOperation(value = "新增重大危险源信息表")
    @PostMapping(value = "data/major/hazard/info")
    public Result insertHazardInfo(@RequestBody @Valid MajorHazardInfoInsertDTO majorHazardInfoInsertDTO) {
        return majorHazardInfoService.insertHazardInfo(majorHazardInfoInsertDTO);
    }

    @ApiOperation(value = "删除重大危险源信息表")
    @DeleteMapping(value = "data/major/hazard/info/{id}")
    public Result deleteHazardInfo(@PathVariable @NotNull Long id) {
        return majorHazardInfoService.deleteHazardInfo(id);
    }

    @ApiOperation(value = "查询重大危险源信息详情")
    @GetMapping(value = "data/major/hazard/info/{id}")
    public Result getHazardInfoDetail(@PathVariable @NotNull Long id) {
        return majorHazardInfoService.getHazardInfoDetail(id);
    }

    @ApiOperation(value = "重大危险源统计")
    @GetMapping(value = "data/major/hazard/statistics")
    public Result getHazardInfoStatistics() {
        return majorHazardInfoService.getHazardInfoStatistics();
    }

    @ApiOperation(value = "首页重大危险源统计")
    @GetMapping(value = "homepage/major/hazard/statistics")
    public Result getHomePageHazardInfoStatistics() {
        return majorHazardInfoService.getHomePageHazardInfoStatistics();
    }

    @ApiOperation(value = "重大危险源组成单元列表")
    @GetMapping(value = "data/major/hazard/partUnit")
    public Result partUnit(@RequestParam("entprId") Long entprId, @RequestParam("partType") Integer partType) {
        return majorHazardInfoService.partUnit(entprId, partType);
    }

    @ApiOperation(value = "传感器，摄像头，重大危险源名称")
    @GetMapping(value = "data/major/hazard/MajorHazardName")
    public Result MajorHazardName(@RequestParam Long entprId) {
        return majorHazardInfoService.MajorHazardName(entprId);
    }

    @ApiOperation(value = "传感器，摄像头，重大危险源类型")
    @GetMapping(value = "data/major/hazard/MajorHazardType")
    public Result MajorHazardType(@RequestParam Long majorHazardId) {
        return majorHazardInfoService.MajorHazardType(majorHazardId);
    }

    @ApiOperation(value = "重大危险源备案")
    @PostMapping(value = "data/major/hazard/MajorHazardFiling")
    public Result MajorHazardFiling(@RequestBody @Valid  MajorHazardExamineDTO majorHazardId) {
        return majorHazardInfoService.MajorHazardFiling(majorHazardId);
    }
}